using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Testing_CreateVenueAddresses : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        PlacementManager.VenueComponent oVenueC = new PlacementManager.VenueComponent();
        List<PlacementManager.Venue> oVenueList = oVenueC.SelectAllActiveWithOutAddress("VenueName");

        PlacementManager.AddressComponent oAddressC = new PlacementManager.AddressComponent();
        PlacementManager.LinkVenueAddressComponent oLvaC = new PlacementManager.LinkVenueAddressComponent();
        if (oVenueList.Count > 0)
        {
            foreach(PlacementManager.Venue oVenue in oVenueList)
            {
                //Create an address record
                PlacementManager.Address oAddress = new PlacementManager.Address();
                oAddress.Address1 = "";
                oAddress.Address2 = "";
                oAddress.City = "";
                oAddress.CountryId = 14;
                oAddress.CreatedBy = "msmithers";
                oAddress.DateCreated = DateTime.Now;
                oAddress.DateUpdated = DateTime.Now;
                oAddress.IsActive = true;
                oAddress.IsPostal = true;
                oAddress.Latitude = 0;
                oAddress.Longitude = 0;
                oAddress.PostCode = "";
                oAddress.StateId = 2;
                oAddress.Street = "";
                oAddress.UpdatedBy = "msmithers";

                int addressid = oAddressC.Insert(oAddress);

                PlacementManager.LinkVenueAddress oLva = new PlacementManager.LinkVenueAddress();
                oLva.AddressId = addressid;
                oLva.CreatedBy = "msmithers";
                oLva.DateCreated = DateTime.Now;
                oLva.DateUpdated = DateTime.Now;
                oLva.IsActive = true;
                oLva.IsPrimary = true;
                oLva.UpdatedBy = "msmithers";
                oLva.VenueId = oVenue.VenueId;
                oLvaC.Insert(oLva);

            }
        }
        this.Label1.Text = "Done";
    }
}
